<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习五：定义一个函数，传入一个数组，对数组进行翻转</title>
  </head>

  <body>

  </body>
  <script>
    /* 
  练习五：定义一个函数，传入一个数组，对数组进行翻转
  */
    var reverseArray = function (arr) {
      var temp;
      for (let i = 0; i < arr.length / 2; i++) {
        temp = arr[i];
        arr[i] = arr[arr.length - 1 - i];
        arr[arr.length - 1 - i] = temp;
      }
      //return arr;这里根本不需要return arr，因为数组是引用传递
    }

    var arr = [10, 1, 3, 50, 6];
    arr = reverseArray(arr);
    console.log(arr); //[6,50,3,1,10]
  </script>

</html>